#include <stdio.h>

#if 0
int main()
{
    // integer promotion
    // char short int, char + char / char + short / char + int / short +int
    char ch; short sh; int in;
    printf("sizeof(ch) = %d\n",sizeof(ch));
    printf("sizeof(sh) = %d\n",sizeof(sh));
    printf("sizeof(in) = %d\n",sizeof(in));
    printf("sizeof(ch + ch) = %d\n",sizeof(ch + ch));
    printf("sizeof(ch + sh) = %d\n",sizeof(ch + sh));
    printf("sizeof(ch + in) = %d\n",sizeof(ch + in));
    printf("sizeof(sh + in) = %d\n",sizeof(sh + in));


    // 整型提升 ，小范围向大范围的空间转，由于符号扩充的行为，保证了数据的正确性。
//    ch = 127;     // 0111 1111,
//    in = ch;      // 0000 0000 0000 0000 0000 0000 0111 1111,
//    printf("ch = %d\n",ch);
//    printf("in = %d\n",in);

    ch = -1;        // 0111 1111, 1111 1111
    in = ch;        // 0000 0000 0000 0000 0000 0000 0111 1111, 1111 1111 1111 1111 1111 1111 1111 1111
    printf("ch = %d\n",ch);
    printf("in = %d\n",in);

    printf("Hello World!\n");
    return 0;
}

#endif


#if 0
// float4 double8
// int longlong
// int longlong  float  double
int main()
{
    // 类型不匹配输出错误
    float f = 3.4;
    int i = 5;

    printf("f + i = %d\n",f + i);
    printf("f + i = %f\n",f + i);
    printf("sizeof(f + i) = %d\n",sizeof(f + i));

    return 0;
}

#endif

#if 0
int main()
{
    int in = 10;
    float fl = 3.1415;
    #if 0
    in = fl;            //去除小数，整数部分赋值。
    printf("%d\n",in);
    #endif
    #if 0
    fl = in;           // 加小数点
    printf("%f\n",fl);
    #endif


    return 0;
}
#endif

int main()
{
    int a = 10;
    int b = 3;
    printf("%d\n",a/b); // 3
    // 类型强制转换
    printf("%f\n",a/(float)b); // 3.33333


    return 0;
}
